
package io.gps.datatransfer.codec;

import org.apache.mina.core.session.IoSession;
import org.apache.mina.filter.codec.ProtocolCodecFactory;
import org.apache.mina.filter.codec.ProtocolDecoder;
import org.apache.mina.filter.codec.ProtocolEncoder;

/**
 * 设备服务器外接信息编解码设置
 * @author bcs
 * @version 2.0, 2020-11-18 12:02:15 $
 */
public class TCPCodecFactory implements ProtocolCodecFactory {

	private ProtocolDecoder decoder;

	/**
	 * 解码器工厂
	 * @param isServer 是否是服务器端解码器 true 服务器 false 设备 （设备解码器会强制关闭发送无效数据链路）
	 */
	public TCPCodecFactory(boolean isServer) {
		if(isServer){
			decoder = new GpsServerDecoder();
		}else{
			decoder = new GpsDecoder();
		}
	}
	@Override
	public ProtocolEncoder getEncoder(IoSession ioSession) throws Exception {
		return null;
	}

	@Override
	public ProtocolDecoder getDecoder(IoSession ioSession) throws Exception {
		return decoder;
	}
}
